package com.qianli.user.facade.impl.base;

import com.fqgj.common.api.Response;
import com.qianli.user.application.UserBaseInfoApplication;
import com.qianli.user.facade.base.UserBaseInfoServiceFacade;
import com.qianli.user.ro.UserStateCode;
import com.qianli.user.ro.base.UserBaseRO;
import com.qianli.user.ro.base.UserContactRO;
import com.qianli.user.ro.base.UserResidentRO;
import com.qianli.user.ro.base.UserWorkRO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * name:用户基本信息
 * auth:ting.li@qianli-inc.com
 * date:2018/1/2 20:14
 * version: v1.0.0
 **/
@Service("userBaseInfoServiceFacade")
public class UserBaseInfoServiceFacadeImpl implements UserBaseInfoServiceFacade {

    @Autowired
    private UserBaseInfoApplication userBaseInfoApplication;

    /**
     * 保存用户基础信息
     *
     * @param userBase
     * @return
     */
    @Override
    public Response<Boolean> saveUserBase(UserBaseRO userBase) {
        if (null == userBase) {
            //LOGGER.info("UserBaseInfoServiceFacade.saveUserBase param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK, "Parameter can not be empty");
        }
        if (null == userBase.getUserCode()) {
            //LOGGER.info("UserBaseInfoServiceFacade.saveUserBase param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK, "Parameter can not be empty");
        }
        Response<Boolean> response = userBaseInfoApplication.saveUserBase(userBase);
        return response;
    }

    /**
     * 保存用户联系方式
     *
     * @param userContact
     * @return
     */
    @Override
    public Response<Boolean> saveUserContact(UserContactRO userContact) {
        if (null == userContact) {
            //LOGGER.info("UserBaseInfoServiceFacade.saveUserContact param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK, "Parameter can not be empty");
        }
        if (null == userContact.getUserCode()) {
            //LOGGER.info("UserBaseInfoServiceFacade.saveUserContact param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK, "Parameter can not be empty");
        }
        Response<Boolean> response = userBaseInfoApplication.saveUserContact(userContact);
        return response;
    }

    /**
     * 保存居住信息
     *
     * @param resident
     * @return
     */
    @Override
    public Response<Boolean> saveUserResident(UserResidentRO resident) {
        if (null == resident) {
            //LOGGER.info("UserBaseInfoServiceFacade.saveUserResident param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK, "Parameter can not be empty");
        }
        if (null == resident.getUserCode()) {
            //LOGGER.info("UserBaseInfoServiceFacade.saveUserResident param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK, "Parameter can not be empty");
        }
        if (null == resident.getAddress()) {
            //LOGGER.info("UserBaseInfoServiceFacade.saveUserResident param mobile can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK, "Parameter can not be empty");
        }
        Response<Boolean> response = userBaseInfoApplication.saveUserResident(resident);
        return response;
    }

    /**
     * 保存工作信息
     *
     * @param userWork
     * @return
     */
    @Override
    public Response<Boolean> saveUserWork(UserWorkRO userWork) {
        if (null == userWork) {
            //LOGGER.info("UserBaseInfoServiceFacade.saveUserWork param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK, "Parameter can not be empty");
        }
        if (null == userWork.getUserCode()) {
            //LOGGER.info("UserBaseInfoServiceFacade.saveUserWork param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK, "Parameter can not be empty");
        }
        /*if(null == userWork.getCompanyName()){
            LOGGER.info("UserBaseInfoServiceFacade.saveUserWork param companyName can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数companyName不能为空");
        }*/
        Response<Boolean> response = userBaseInfoApplication.saveUserWork(userWork);
        return response;
    }
}
